package supershop3.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import supershop3.dao.IProductDao;
import supershop3.dto.ProductDTO;
import supershop3.model.Product;

@Service
public class ProductServiceImpl implements IProductService {

	@Resource
	private IProductDao productDao;
	@Override
	public int addOrEdit(Product p) {
		if(p.getId()!=null) {
			return productDao.edit(p);
		}else {
			return productDao.add(p);
		}
	}
	@Override
	public List<Product> findAll(ProductDTO dto) {
		return productDao.findAll(dto);
	}
	@Override
	public Object getCount(ProductDTO dto) {
		return productDao.getCount(dto);
	}
	@Override
	public int putaway(int id, String isPutOnSale) {
		return productDao.putaway(id, isPutOnSale);
	}
	@Override
	public int del(int id) {
		return productDao.del(id);
	}
	@Override
	public int recommend(int id, String isToday) {
		// TODO Auto-generated method stub
		return productDao.recommend(id, isToday);
	}
	@Override
	public int updateUrl(int id, String url) {
		return productDao.updateImage(id, url);
	}

}
